<template>
  <div>
    <div v-show="preview">
      <el-image
        v-if="imgSrc"
        :src="imgSrc"
        :previewSrc="[imgSrc]"
        :style="{ height: height + 'px' }"
      ></el-image>
    </div>
    <div>文件id： {{ imgId }}</div>
    <div>文件预览地址： {{ imgSrc }}</div>
  </div>
</template>

<script>
export default {
  name: "FormImage",

  filters: {},
  computed: {
    imgSrc() {
      return this.previewSrc;
    },
    imgId() {
      return this.value;
    },
  },

  props: {
    value: {
      type: String,
      default: "",
    },
    preview: {
      type: Boolean,
      default: false,
    },
    height: {
      type: Number,
      default: 100,
    },
    previewSrc: {
      type: String,
      default: "",
    },
  },
  data() {
    return {};
  },
  methods: {
    onFocus() {
      this.$refs.UserDialog.dialogVisible = true;
    },
    onSelect(obj) {
      this.$emit(
        "input",
        obj.names && obj.ids ? `${obj.names}_*_${obj.ids}` : ""
      );
    },
  },
};
</script>

<style lang="scss" scoped></style>
